//引入列表接口
import { getMenuList } from '../../../request/api'
//定义一个接口类型
interface StateType {
    menulist: Array<Object>
}

const state = {
    menulist: []
}

const getters = {
    getMenu(state: StateType) {
        return state.menulist
    }
}

const mutations = {
    REQ_MENULIST(state: StateType, payload: any) {
        state.menulist = payload
        console.log(state.menulist,'state.menulist')
    }
}

const actions = {
    //封装一个行动
    getMenuAction(context: any) {
        getMenuList()
            .then((res: any) => {
                // console.log(res, 'rrrrrrrrr')
                context.commit('REQ_MENULIST', res.list)
            })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}